/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import pojo.DanhMucPoJo;
import util.DataProvider;

/**
 *
 * @author Kanet
 */
public class DanhMucDao {
    
    public static ArrayList<DanhMucPoJo> laydanhsachDanhMuc()
    {
        ArrayList<DanhMucPoJo> arr = new ArrayList<DanhMucPoJo>();
        String sql = "SELECT * FROM danhmuc";
        DataProvider dp = new DataProvider();
        dp.open();
        ResultSet rs;
        
        try{
            rs = dp.executeQuery(sql);
            while (rs.next()){
                DanhMucPoJo danhmuc = new DanhMucPoJo();
                danhmuc.setIdDanhMuc(rs.getInt("idDanhMuc"));
                danhmuc.setTenDanhMuc(rs.getString("tenDanhMuc"));
                arr.add(danhmuc);
            }            
        }
        catch(SQLException ex){
            System.out.println(ex.getMessage());                        
        }
        dp.close();
        return arr;
    }
}
